package com.youxin.busfoundation.config;

import java.text.ParseException;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

import com.youxin.foundation.utils.HostUtils;

import redis.clients.jedis.HostAndPort;

/**
 * Redis Item
 * @author yingde.cao
 *
 */
public class MonitorRedisItem {
	private String hosts;
	private String type;
	private Set<HostAndPort> hostPorts;
	
	public String getHosts() {
		return hosts;
	}
	public void setHosts(String hosts) {
		this.hosts = hosts;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
	public Set<HostAndPort> getHostPorts() throws ParseException{
		if(hostPorts==null){
			hostPorts=HostUtils.parserHosts(this.hosts);
		}
		return hostPorts;
	}
	
	
	public boolean isCluster(){
		if(StringUtils.isBlank(type)){
			return true;
		}
		return "cluster".equalsIgnoreCase(type);
	}

}
